package com.exam.zhaohang;

import java.util.Arrays;
import java.util.Scanner;

/**
 * date:
 * description:
 */
public class Solution002 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        Arrays.sort(nums);
        int count = 0;
        int left = 0;
        int right = nums.length - 1;
        while(right > left && nums[right] - nums[left] > k){
            count++;
            if(nums[right] - nums[right - 1] > nums[left + 1] - nums[left]){
                right--;
            }else{
                left++;
            }
        }
        System.out.println(count);

    }
}
